DC Motor 32 Click
DC Motor 32 Click demo application is developed using the NECTO Studio, ensuring compatibility with mikroSDK's open-source libraries and tools. Designed for plug-and-play implementation and testing, the demo is fully compatible with all development, starter, and mikromedia boards featuring a mikroBUS™ socket.
Click Library
- Author : Stefan Filipovic
- Date : Mar 2026.
- Type : SPI type
Software Support
Example Description
This example demonstrates the use of the DC Motor 32 Click board for controlling a DC motor. The application switches between different operation modes (forward, brake, reverse, and off) and measures the output current in each state.
Example Libraries
- MikroSDK.Board
- MikroSDK.Log
- Click.DCMotor32
Example Key Functions
- dcmotor32_cfg_setup This function initializes Click configuration structure to initial values.
void dcmotor32_cfg_setup(dcmotor32_cfg_t *cfg)
DC Motor 32 configuration object setup function.
DC Motor 32 Click configuration object.
Definition dcmotor32.h:194
- dcmotor32_init This function initializes all necessary pins and peripherals used for this Click board.
err_t dcmotor32_init(dcmotor32_t *ctx, dcmotor32_cfg_t *cfg)
DC Motor 32 initialization function.
DC Motor 32 Click context object.
Definition dcmotor32.h:176
- dcmotor32_default_cfg This function executes a default configuration of DC Motor 32 Click board.
err_t dcmotor32_default_cfg(dcmotor32_t *ctx)
DC Motor 32 default configuration function.
- dcmotor32_set_operation_mode This function sets the selected device operation mode.
err_t dcmotor32_set_operation_mode(dcmotor32_t *ctx, uint8_t mode)
DC Motor 32 set operation mode function.
- dcmotor32_get_out_current This function calculates the output current from the measured ADC voltage.
err_t dcmotor32_get_out_current(dcmotor32_t *ctx, float *current)
DC Motor 32 get output current function.
Application Init
Initializes the logger and DC Motor 32 Click driver, and applies the default configuration.
{
log_cfg_t log_cfg;
LOG_MAP_USB_UART( log_cfg );
log_init( &logger, &log_cfg );
log_info( &logger, " Application Init " );
{
log_error( &logger, " Communication init." );
for ( ; ; );
}
{
log_error( &logger, " Default configuration." );
for ( ; ; );
}
log_info( &logger, " Application Task " );
}
@ DCMOTOR32_OK
Definition dcmotor32.h:215
#define DCMOTOR32_MAP_MIKROBUS(cfg, mikrobus)
MikroBUS pin mapping.
Definition dcmotor32.h:161
void application_init(void)
Definition main.c:36
#define MIKROBUS_POSITION_DCMOTOR32
Definition main.c:30
Application Task
Cycles through motor operation modes, measures the output current, and logs the results to the serial terminal.
{
float current = 0;
{
log_printf( &logger, " MODE: Forward\r\n\n" );
Delay_ms ( 1000 );
Delay_ms ( 1000 );
{
log_printf( &logger, " Current : %.3f A\r\n\n", current );
}
}
{
log_printf( &logger, " MODE: Brake\r\n\n" );
Delay_ms ( 1000 );
Delay_ms ( 1000 );
{
log_printf( &logger, " Current : %.3f A\r\n\n", current );
}
}
{
log_printf( &logger, " MODE: Reverse\r\n\n" );
Delay_ms ( 1000 );
Delay_ms ( 1000 );
{
log_printf( &logger, " Current : %.3f A\r\n\n", current );
}
}
{
log_printf( &logger, " MODE: Off\r\n\n" );
Delay_ms ( 1000 );
Delay_ms ( 1000 );
{
log_printf( &logger, " Current : %.3f A\r\n\n", current );
}
}
}
#define DCMOTOR32_CONTROL_MODE_HALF_BRIDGE_A_TRI_STATE
Definition dcmotor32.h:90
#define DCMOTOR32_CONTROL_MODE_SLOW_DECAY_LSA
Definition dcmotor32.h:79
#define DCMOTOR32_CONTROL_MODE_FORWARD_HSB
Definition dcmotor32.h:82
#define DCMOTOR32_CONTROL_MODE_REVERSE_HSA
Definition dcmotor32.h:87
void application_task(void)
Definition main.c:72
Application Output
This Click board can be interfaced and monitored in two ways:
- Application Output - Use the "Application Output" window in Debug mode for real-time data monitoring. Set it up properly by following this tutorial.
- UART Terminal - Monitor data via the UART Terminal using a USB to UART converter. For detailed instructions, check out this tutorial.
Additional Notes and Information
The complete application code and a ready-to-use project are available through the NECTO Studio Package Manager for direct installation in the NECTO Studio. The application code can also be found on the MIKROE GitHub account.